package com.wushi.lenovo.asia5b.app_model.good.goodbean;

import android.content.Context;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;

import com.google.gson.annotations.SerializedName;
import com.mvp.base.model.BaseModel;
import com.wushi.lenovo.asia5b.R;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * Created by zhangyuncai on 2019/11/2.
 * 订单商品详情
 */
public class OrderGoodBean extends GoodsModelIml implements Serializable {

    public boolean isChecked;
    /**
     * id : 61
     * product_id : 167
     * product_name : 2018夏季新款字母短袖T恤+宽松显瘦休闲裤德芙裤运动裤九分裤时尚套装两件套女
     * image : https://s11.mogucdn.com/mlcdn/c45406/180428_382177fi446686lejjk8laa8i8acd_640x850.jpg
     * quantity : 3
     * weight : 6.60
     * price : RM 106.64
     * diff_price : RM 0.00
     * diff_domestic : RM 2.48
     * kgorm3 : kg
     * is_sensitive : 0
     * status_name : 已付款
     * remark :
     * action : []
     * attr_name : 蓝色T恤,XL
     */
    private int id;
    private int product_id;
    @SerializedName(value = "product_name", alternate = {"name"})
    private String product_name;
    private String image;
    private String option;//"20509:28315,1627207:3232481",
    public String unit_price;//"RM 11.61",//带单位的单价
    public String domestic;// "-"
    private int quantity;
    public int show_parcel_track;//是否有物流信息
    private String weight;//总重
    private String price;//带单位的总价 RM 69.66
    private String total_price;//该商品付款总价带单位
    private String total_price_value;//该商品付款总价
    private String is_sensitive;//Not sensitive = 0, Is sensitive = 1
    private String status_name;
    private String remark;
    private String attr_name;
    private String ng_description;
    private String status_color;
    private String m3_weight;
    private List<ActionBean> action;
    private List<String> ng_images;
    private int pay_type = 1;//付款类型,普通付款:1  其他补差价付款!=1,默认是普通付款,在处理中的订单商品列表中,==3表示可以付款
    private String volume_weight;
    private String diff_total;//带单位的差价
    private String diff_total_value;//不带单位的差价
    private String storage_text;//存储数量
    private String storage_day_num;//存储天数
    private int storage_total_days;//存储总共天数

    @Override
    public String getStorage_day_num() {
        return storage_day_num;
    }

    public int getStorage_total_days() {
        return storage_total_days;
    }

    public String getDiff_total() {
        return diff_total;
    }

    public String getDiff_total_value() {
        return diff_total_value;
    }

    public String getVolume_weight() {
        return volume_weight;
    }

    public int getPay_type() {
        return pay_type;
    }

    public String getM3_weight() {
        return m3_weight;
    }

    public int getStatus_color(Context context) {
        int color;
        try {
            color = Color.parseColor(status_color);
        } catch (Exception e) {
            e.printStackTrace();
            color = ContextCompat.getColor(context, R.color.colorPrimaryDark);
        }
        return color;
    }

    public List<String> getNg_images() {
        return ng_images;
    }

    public void setNg_images(List<String> ng_images) {
        this.ng_images = ng_images;
    }

    public String getNg_description() {
        return ng_description;
    }


    public int getId() {
        return id;
    }

    public int getProduct_id() {
        return product_id;
    }

    public String getProduct_name() {
        return product_name;
    }

    public String getImage() {
        return image;
    }

    public int getQuantity() {
        return quantity;
    }

    public String getWeight() {
        return weight;
    }

    @Override
    public String goodsName() {
        return product_name;
    }

    @Override
    public int goodsId() {
        return product_id;
    }

    @Override
    public String goodsImg() {
        return image;
    }

    @Override
    public int parcelno() {
        return id;
    }

    @Override
    public String goodsAttr() {
        return attr_name;
    }

    @Override
    public String goodsUnitPrice() {
        return containsRM(unit_price);
    }

    @Override
    public String goodsTotalPrice() {
        return containsRM(price);
    }

    @Override
    public int goodsQuantity() {
        return quantity;
    }

    public boolean isMingan() {
        return TextUtils.equals(is_sensitive, "1");
    }

    @Override
    public String chinaDeliveryFee() {
        return containsRM(domestic);
    }

    @Override
    public String totalDiffPrice() {
        if (!TextUtils.isEmpty(diff_total)) {
            return containsRM(diff_total);
        }
        return null;
    }

    @Override
    public String zongjiPrice() {
        return containsRM(total_price);
    }

    @Override
    public String goodsTotalWeight() {
        return containsKG(weight);
    }

    @Override
    public String goodsTotalVolWeight() {
        return containsKG(volume_weight);
    }

    @Override
    public String goodsTotalM3Weight() {
        return containsM3(m3_weight);
    }

    public String getStatus_name() {
        return status_name;
    }

    @Override
    public String getRemark() {
        return remark;
    }

    public String getAttr_name() {
        return attr_name;
    }


    public List<ActionBean> getAction() {
        return action;
    }

    public static class ActionBean implements Serializable {

        /**
         * code : button_reverify
         * ajaxURL : https://asia-allnet.com/api/mobile-v1/orderdg.detail.reverify
         * param : {"id":28807,"order_id":230}
         */

        private String code;//Button code
        private String name;//Button name
        private String popup_title;//Popup Title
        private String popup_content;//Popup Content
        private String popup_content_title_explain;//Only For Cancel Order Popup label name when reason > ID=3(Others),Please elaborate it
        private String popup_content_ph_explain;//Only For Cancel Order Popup place holder when reason > Please remark why you want to cancel this order
        private ParamBean param;
        private Popup_buttonBean popup_button_left;
        private Popup_buttonBean popup_button_right;
        private int enabled = 1;//0/1 不可点击/可点击

        public int getEnabled() {
            return enabled;
        }

        public String getName() {
            if (TextUtils.isEmpty(name)) {
                return code;
            }
            return name;
        }

        public String getPopup_title() {
            return popup_title;
        }

        public String getPopup_content() {
            return popup_content;
        }

        public String getPopup_content_title_explain() {
            return popup_content_title_explain;
        }

        public String getPopup_content_ph_explain() {
            return popup_content_ph_explain;
        }

        public Popup_buttonBean getPopup_button_left() {
            if (popup_button_left == null) {
                return new Popup_buttonBean();
            }
            return popup_button_left;
        }

        public Popup_buttonBean getPopup_button_right() {
            if (popup_button_right == null) {
                return new Popup_buttonBean();
            }
            return popup_button_right;
        }

        public String getCode() {
            return code;
        }


        public ParamBean getParam() {
            if (param == null) {
                param = new ParamBean();
            }
            return param;
        }

        public static class ParamBean implements Serializable {
            /**
             * id : 28807
             * order_id : 230
             */

            private int ng_details_id;

            public int getNg_details_id() {
                return ng_details_id;
            }
        }
    }

    public static class Popup_buttonBean extends BaseModel {

        /**
         * name : Yes, I want to cancel
         * ajaxURL : https://asia-allnet.com/api/mobile-v1/orderdg.detail.cancel
         * ajaxUrlSuffix : orderdg.detail.completed
         * param : {"id":129763}
         */

        private String name;
        private String ajaxURL;
        private String ajaxUrlSuffix;
        ;
        private Map<String, String> param;

        public String getAjaxUrlSuffix() {
            return ajaxUrlSuffix;
        }

        public String getName() {
            return name;
        }

        public String getAjaxURL() {
            return ajaxURL;
        }

        public Map<String, String> getParam() {
            return param;
        }

    }
}
